<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/WEB-INF/include/header.jsp" %>
<style>
    div { margin: 10px 0; }
</style>
<script>
$(function() {
    if (window.parent) {
        var h = $("html").height();
        $('iframe[src*=test3_inner1]', window.parent.document).css("height", h);
    }
});
</script>
</head>
<%
if ("reset".equals(request.getParameter("cmd"))) {
    session.removeAttribute("count");
    session.removeAttribute("list");
}

Integer count = (Integer)session.getAttribute("count");
if (count == null) count = 1;
else count = count + 1;
session.setAttribute("count", count);

@SuppressWarnings("unchecked")
ArrayList<Date> list = (ArrayList<Date>)session.getAttribute("list");
if (list == null) {
    list = new ArrayList<Date>();
    session.setAttribute("list", list);
}
list.add(new Date());
%>
<body>

<div class="container">

    <form>
        <h3>Session Count: <%= count %></h3>
        <button type="submit" class="btn" name="cmd" value="count">count</button>
        <button type="submit" class="btn" name="cmd" value="reset">reset</button>
    </form>

    <% for (Object s : list) { %>
        <div><%= s %></div>
    <% } %>

</div>

</body>
</html>